package cn.hxsteel.storage.core.servlet;

import java.io.IOException;
import java.util.Properties;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;

import org.springframework.core.io.ClassPathResource;

import cn.hxsteel.jtool.util.ConverterUtil;
import cn.hxsteel.storage.core.config.Config;

/**
 * 初始化配置参数
 */
@WebServlet( value = "/CofigServlet", loadOnStartup = 1 )
public class ConfigServlet extends HttpServlet
{
    /**
     * 初始化配置
     */
    public void init()
	    throws ServletException
    {
	ClassPathResource cr = new ClassPathResource( "config.properties" ); // 会重新加载spring框架
	Properties prop = new Properties();
	try
	{
	    prop.load( cr.getInputStream() );
	    Config.tempturnoverWebserviceDomain = prop.getProperty( "config.tempturnoverWebserviceDomain" );
	    Config.DEBUG = ConverterUtil.toBoolean( prop.getProperty( "config.debug" ) );
	}
	catch ( IOException e )
	{
	    e.printStackTrace();
	}
    }
}
